package neuralmusic.brain.ga;


import java.io.PrintStream;
import java.lang.reflect.Array;

public class Token {

	public Type type;
	public Object data;

	public Token(Type type, Object data) {
		this.type = type;
		this.data = data;
	}

	public void print(PrintStream out) {
		if (data == null) {
			out.println(type + ":null");
		} else {
			if (data.getClass().isArray()) {
				out.print(type + ":");

				for (int i=0;i<Array.getLength(data);i++) {
					out.print(" " + Array.get(data,i));
				}
				out.println();
			} else {
				out.println(type + ":" + data);
			}
		}
	}

}
